﻿Public Class Activity

    Private _UserId As Integer

    Public Enum ActivityType
        atUnknown
        atRelationship
        atChild
        atSponsor
        atFamily
        atUsers
        atParent
    End Enum

    Sub New(ByVal UserId As Integer)
        _UserId = UserId
    End Sub

    
    Public Function AddRecentActivity(ByVal eType As Activity.ActivityType, ByVal ActivityId As Integer)

        Dim params As New List(Of IDataParameter)

        Dim param As IDataParameter

        param = DatabaseLayer.DatabaseManager.InputParameter("UserId",
                                                        DbType.Int32,
                                                        _UserId)
        params.Add(param)

        param = DatabaseLayer.DatabaseManager.InputParameter("ActivityTypeId",
                                                        DbType.Int32,
                                                        eType)
        params.Add(param)

        param = DatabaseLayer.DatabaseManager.InputParameter("ActivityId",
                                                        DbType.Int32,
                                                        ActivityId)
        params.Add(param)

        Dim lRet As Integer = DatabaseLayer.DatabaseManager.StoredProc("uspAddUserActivity", params, User.CurrentUser.ID)

        Return lRet

    End Function

    Public Function RecentActivity(ByVal Activities As Integer, ByVal AT As ActivityType) As DataTable

        Dim params As New List(Of IDataParameter)
        Dim dt As New DataTable
        Dim param As IDataParameter

        param = DatabaseLayer.DatabaseManager.InputParameter("UserId",
                                                        DbType.Int32,
                                                        User.CurrentUser.ID)
        params.Add(param)



        param = DatabaseLayer.DatabaseManager.InputParameter("Rows",
                                                        DbType.Int32,
                                                        Activities)
        params.Add(param)

        param = DatabaseLayer.DatabaseManager.InputParameter("ActivityTypeId",
                                                            DbType.Int32,
                                                            AT)
        params.Add(param)



        Dim lRet As Integer = DatabaseLayer.DatabaseManager.StoredProc("uspGetUserActivity", params, dt, User.CurrentUser.ID)

        Return dt

    End Function

    Public Shared Function ActivityTypes() As DataTable
        Dim dt As New DataTable
        Dim lRet As Integer = DatabaseLayer.DatabaseManager.StoredProc("uspGetActivityTypes", dt, User.CurrentUser.ID)

        Return dt
    End Function

End Class
